import './style/topComponent.css'
type TopComponentProps = {
    title: string;
    goBack?: () => void; // 可选的无参数、无返回值函数
    handleGoBack1?: () => void; // 可选的无参数、无返回值函数
    handleGoBack2?: () => void; // 可选的无参数、无返回值函数
  };
const TopComponent:React.FC<TopComponentProps> = ({title,goBack,handleGoBack1,handleGoBack2}) => {
   const handleRouter = () => {
    if( title === "1" ){
        handleGoBack1?.()
    }
    if( title === "2" ){
        goBack?.()
    }
    if( title === "3" ){
        handleGoBack2?.()
    }
   }
    return (
        <>
            <div className="parentBox-top">
                <span className='parentBox-doLogin'>
                    {title === "1" ? "登录" : title === "2" ? "忘记密码" : title === "3" ? "注册" : "找回密码"}
                </span>
                <span className='parentBox-cha' onClick={()=>{handleRouter()}}>×</span>
            </div>
        </>
    )
}
export default TopComponent;